package com.cn.shop.service.impl;

import com.cn.shop.dao.ManageDao;
import com.cn.shop.service.ManageService;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * 后管系统
 *
 * @author suhao
 * @time 2018-03-17
 * @email suhao755@gmail.com
 */
@Service
public class ManageServiceImpl implements ManageService {
    private ManageDao manageDao;
    @Autowired
    public ManageServiceImpl(ManageDao manageDao) {
        this.manageDao = manageDao;
    }

    @Override
    public List getUserList() {
        return manageDao.getUserLists();
    }

    @Override
    public String deleteUser(String cifSeq) {
        int result = manageDao.selectUserByCifSeq(cifSeq);
        if(result > 0){
            manageDao.deleteUser(cifSeq);
            return "删除成功!";
        }else{
            return "用户不存在!";
        }
    }

    @Override
    public List getNoticeList() {
        return manageDao.getNoticeLists();
    }

    @Override
    public Map getNoticeDetail(int noticeId) {
        return manageDao.getNoticeDetail(noticeId);
    }

    @Override
    public String deleteNotice(int noticeId) {
        manageDao.deleteNotice(noticeId);
        return "删除成功!";
    }

    @Override
    public String addNotice(Map params) {
        manageDao.addNotice(params);
        return "添加成功!";
    }

    @Override
    public String updateNotice(int noticeId, String noticeContent) {
        manageDao.updateNotice(noticeId,noticeContent);
        return "修改成功!";
    }
}
